<template>
	<view class="subscribe">
		<view class="title">订阅价格</view>
		<view class="inpDad">
			<input class="inp" placeholder="订阅价格需要≥10/月" border="none" type="number" v-model.trim="parameter.subscribe_price" />
		</view>
		<view class="title">备注</view>
		<textarea class="textarea" placeholder="请输入简介" v-model="parameter.subscribe_desc" />
		<view class="btn" @click="setSubscribePrice">
			保存
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				parameter: {
					subscribe_price: "",
					subscribe_desc: ""
				},
			}
		},
		onShow() {
			this.parameter.subscribe_price = uni.getStorageSync("user").subscribe_price
			this.parameter.subscribe_desc = uni.getStorageSync("user").subscribe_desc
		},
		methods: {
			//设置订阅价格
			async setSubscribePrice() {
				if (!this.parameter.subscribe_price) {
					uni.showToast({
						title: '请输入订阅价格',
						icon: "none",
					})
					return
				}
				// if(this.parameter.subscribe_price < 10) {
				// 	uni.showToast({
				// 		title: '订阅价格不能小于10',
				// 		icon:"none",
				// 	})
				// 	return
				// }
				let res = await this.$http("api/user/setSubscribePrice", this.parameter)
				// console.log(res);
				if (res.code == 200) {
					uni.showToast({
						title: "设置成功",
						icon: 'none',
					})
					setTimeout(() => {
						this.navigateBack()
					}, 1500);
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.subscribe {
		padding: 16rpx 32rpx;

		.title {
			font-weight: 800;
			font-size: 32rpx;
			color: #333333;
			padding-bottom: 32rpx;
		}

		.inpDad {
			width: 638rpx;
			padding: 48rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			margin: 0 auto 48rpx;

			.inp {
				font-weight: bold;
				font-size: 28rpx;

				.input-placeholder {
					font-weight: bold;
					font-size: 28rpx;
					color: #CACACA;
				}
			}
		}

		.textarea {
			width: 638rpx;
			height: 180rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			font-weight: bold;
			font-size: 28rpx;
			margin: auto;
			padding: 28rpx;
			box-sizing: border-box;

			.uni-textarea-placeholder {
				font-weight: bold;
				font-size: 28rpx;
				color: #CACACA;
			}
		}

		.btn {
			position: fixed;
			left: 50%;
			bottom: 100rpx;
			transform: translateX(-50%);
			width: 606rpx;
			height: 96rpx;
			background: #333333;
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			line-height: 96rpx;
			text-align: center;
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
		}
	}
</style>